package com.baba.emq.bean;

/**
 * @author wulongbo
 * @version 1.0
 * @date 2020/6/4 13:43
 * @description
 */

import cn.hutool.json.JSONObject;
import lombok.Data;
import lombok.Getter;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;

/**
 * 发布的消息封装
 *
 */
@Component
@Data
public class PublishBean {

    @Value("${spring.mqtt.username}")
    private String username;

    @Value("${spring.mqtt.password}")
    private String password;

    @Value("${spring.mqtt.host}")
    private String host;

    @Value("${spring.mqtt.port}")
    private String port;

    @Value("${spring.mqtt.clientId}")
    private String clientId;

    @Value("${spring.mqtt.topic}")
    private String topic;

    @Value("${spring.mqtt.device.prefix}")
    private String TOPIC_PREFIX_DEVICE;

    @Value("${spring.mqtt.device.sufix}")
    private String TOPIC_SUFIX_DEVICE;

    @Value("${spring.mqtt.app.prefix}")
    private String TOPIC_PREFIX_APP;

    @Value("${spring.mqtt.app.sufix}")
    private String TOPIC_SUFIX_APP;

    @Value("${spring.mqtt.qos}")
    private int qos;

    @Value("${spring.mqtt.retained}")
    private boolean retained ;

    @Value("${spring.mqtt.dup}")
    private boolean dup;

    @Value("${spring.mqtt.mutable}")
    private boolean mutable;

    private JSONObject payload;

    @Value("${spring.mqtt.completionTimeout}")
    private int completionTimeout;   //连接超时

    public  String getDevicePublishTopic(String deviceId) {
        return TOPIC_PREFIX_DEVICE + "/" + deviceId + "/server";
    }


    public  String getAppPublishTopic(String deviceId) {
        return TOPIC_PREFIX_APP + "/" + deviceId + "/server";
    }

}
